<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:76:"D:\phpStudy\WWW\fastAdmin\public/../application/food\view\index\comment.html";i:1526521604;s:64:"D:\phpStudy\WWW\fastAdmin\application\food\view\common\base.html";i:1526525827;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>
    
走心更走胃-留言板

    </title>
    <link rel="stylesheet" type="text/css" href="/static/css/index.css" />
    
<link rel="stylesheet" href="/static/css/comment.css">

</head>

<body>
<!--头部开始-->
<header>
    <div class="logo"><img src="/static/images/logo.jpg" alt="" class="lazyload"></div>
    <div class="nav">
        <ul>
            <li><a href="/food">首页</a></li>
            <li><a href="#">关于我们</a></li>
            <li><a href="#">热量计算</a></li>
            <li><a href="food/comment">网站反馈</a></li>
        </ul>
    </div>
    <div class="search">
        <form action="/list">
            <input type="text" name="name">
        </form>
        <img src="/static/images/search.png" class="searchBtn lazyload">
    </div>
    <div class="login">
        <ul>
            <?php if(null ===\think\Session::get('user')): ?>
            <li><a href="<?php echo url('food/auth/register'); ?>">注册</a></li>
            <li><a href="<?php echo url('food/auth/login'); ?>">登录</a></li>
            <?php else: ?>
            <li style="margin-left: -20px;"><a href="#">欢迎您，<?php echo \think\Session::get('user.phone'); ?></a></li>
            <li><a href="/logout">退出</a></li>
            <?php endif; ?>
        </ul>
    </div>
</header>
<!--头部结束-->



<div class="wrapper">
    
<div class="message">
    <!-- 留言部分开始 -->
    <div class="m-t">欢迎留言<i>Welcome to leave your messages</i></div>
    <div class="m-c">
        <div class="m-t">
            <dl>留言板</dl>
            <dt>发表您的留言</dt>
            <?php if(\think\Session::get('commentError')): ?>
            <dt><?php echo \think\Session::get('commentError'); ?></dt>
            <?php endif; ?>
        </div>
        <form action="/comment" method="post">
            <div class="m-c">
                <textarea name="content" rows="10" cols="145"></textarea>
            </div>
            <?php if(\think\Cookie::get('uid')): ?>
            <input type="submit" value="发表" style="cursor:pointer;" class="submit">
            <?php else: ?>
            <input type="button" value="发表" style="cursor:pointer;" onclick="alert('您还没登录，请先登录~');location.href='/login'">
            <?php endif; ?>
        </form>
    </div>
    <!-- 留言部分结束 -->
    <!-- 留言显示部分开始 -->
    <div class="m-b">
        <dl>留言(<span><?php echo $comments->total(); ?></span>条)</dl>
        <?php if(is_array($comments) || $comments instanceof \think\Collection || $comments instanceof \think\Paginator): $i = 0; $__LIST__ = $comments;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$comment): $mod = ($i % 2 );++$i;?>
        <div class="content">
            <?php echo $comment->content; if(\think\Session::get('user.id') == $comment['user_id']): ?>
            <p class="delete" onclick="del(<?php echo $comment->id; ?>)" data-id="">删除</p>
            <?php endif; ?>
        </div>
        <?php endforeach; endif; else: echo "" ;endif; ?>
        <div class="content">
            <?php echo $page; ?>
        </div>
    </div>
    <!-- 留言显示部分结束 -->
</div>

    <footer>
        <!--底部开始-->
        <div class="line">
            <h3>走胃更走心---吃得健康又营养!</h3>
        </div>
        <p class="link">友情链接: <a href="http://life.iqiyi.com/">爱奇艺生活</a> <a href="http://www.zhms.cn/">中华美食网</a>
            <a href="http://www.pcbaby.com.cn/">太平洋亲子网</a> <a href="http://food.poco.cn/">POCO美食网</a>
            <a href="http://www.21food.cn/">食品商务网</a> <a href="http://www.mama.cn/">妈妈网</a>
            <a href="http://www.39yst.com/">三九养生堂</a> <a href="http://www.258.com/">企业服务平台</a>
            <a href="http://www.yidianzixun.com/">一点资讯</a> <a href="http://www.hc360.com/">慧聪网</a>
        </p>
        <p class="copyright">版权所有 © 2004-2019 走心更走胃 保留所有权利</p>
        <!--底部结束-->
    </footer>
</div>
<script src="/static/js/jquery-1.11.1.js"></script>
<script src="/static/js/slider.min.js"></script>
<script type="text/javascript" src="//cdn.bootcss.com/jquery.lazyload/1.9.1/jquery.lazyload.min.js" ></script>

<script>
    function del(id) {
        if(confirm('确认删除么？')) {
            $.ajax({
                url: '/comment',
                method: 'delete',
                data: {id: id},
                success: function(res) {
                    if(res.code > 0) {
                        alert(res.msg)
                        location.reload();
                    }else {
                        alert(res.msg)
                    }
                }
            })
        }
    }
    (function () {
        $('textarea').val('')
        setTimeout(function () {
            $('.m-t dt').eq(1).fadeOut()
        }, 2000)
    })()
</script>

</body>
</html>